--[[/**
-- * 
 * 所受伤害由目标代替我承受
 * [0] n 万分比
-- *
-- */]]

---@class BuffEffect92042102 : BaseBuffEffect
BuffEffect92042102 = ClientFight.CreateClass("BuffEffect92042102", ClientFight.BaseBuffEffect)
local t = BuffEffect92042102

---@param fight Fight
---@param buff FighterBuff
function t:action(fight, buff, ...)
    local parameters = {...};
    if (not buff.target:isSummons()) then
        return IBuffEffect.FAIL;
    end
    local buffEffectValueTemp = buff.buffBean.f_BuffEffectValueTemp;
    SkillRoleMgr.savePathFile(string.format("[%s][EFFECT]Fighter %s Buff%s 强行修正生命上限为,不超过 %s",
            fight.frame, buff.target.fighterId, buff.modelId, buffEffectValueTemp[1]));
    local target = buff.target;
    local maxHp = FighterAttributeManager.getFightAttr(target, FighterAttributeEnum.HP);
    if (maxHp <= buffEffectValueTemp[1]) then
        return IBuffEffect.FAIL;
    end
    local reduce = buffEffectValueTemp[1] - maxHp;
    buff.attributes.attributes[FighterAttributeEnum.HP.id] = reduce;
    return IBuffEffect.SUCCESS_ATTRI_HAS_CHANGE;
end

t.New()